/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package vista;

import dao.DAOProvincia;
import entidades.Provincia;
import entidades.Vendedor;
import java.util.Vector;

/**
 *
 * @author Rodri
 */
public class VPrincipal extends javax.swing.JFrame {

    /**
     * Tipo enumerado para identificar la vista activa de la ventana principal
     * 
     * @author Nacho
     */
    private enum TipoEntidad{
        INMUEBLES,
        CLIENTES,
        PROPIETARIOS;
    }
    
    /**
     * Provincias y sus localidades
     * 
     * @author Rodri
     */
    public static Vector<Provincia> provincias = DAOProvincia.getAll();

    /**
     * Codigos de los inmuebles seleccionados para generar catalogo
     * 
     * @author Rodri
     */
    public static Vector<String> codigos = new Vector<String>();

    /**
    * Tipos de inmuebles
    * 
    * @author Simon
    */
    private enum TipoInmueble{
        L, C, D, T, Q, G;
    }
   
    /** !!!!!!!!!!! ESTA DUPLICADO EN EL PANEL DE LISTADO INMUEBLE, NO SE SI VA ACA
     * Id que recibo de la búsqueda de cliente para crear catálogo
     * 
     * @author Rodri
     */
    private String id_cliente;

    public void setIdCliente(String id_cliente) 
    {
        this.id_cliente = id_cliente;
    }

    /**
     * objeto sesion para almacenar el vendedor que esta utilizando el sistema
     */
    public static Vendedor vLogeado;
    
    /**
     * Creates new form VentanaPrincipal
     * @param vLogeado
     */
    public VPrincipal(Vendedor vLogeado) 
    {
        initComponents();
        this.lpPrincipal.add(new PListadoInmuebles());
        this.getContentPane().revalidate();
        VPrincipal.vLogeado = vLogeado;
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jToolBar1 = new javax.swing.JToolBar();
        bInmuebles = new javax.swing.JButton();
        bClientes = new javax.swing.JButton();
        bPropietarios = new javax.swing.JButton();
        lpPrincipal = new javax.swing.JLayeredPane();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Inmobiliaria FRSF");
        setName("vPrincipal"); // NOI18N
        setResizable(false);

        jToolBar1.setFloatable(false);
        jToolBar1.setRollover(true);

        bInmuebles.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconos/home_32.png"))); // NOI18N
        bInmuebles.setText("Inmuebles");
        bInmuebles.setFocusable(false);
        bInmuebles.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        bInmuebles.setName("bInmuebles"); // NOI18N
        bInmuebles.setSelected(true);
        bInmuebles.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        bInmuebles.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bInmueblesActionPerformed(evt);
            }
        });
        jToolBar1.add(bInmuebles);

        bClientes.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconos/user_blue_32.png"))); // NOI18N
        bClientes.setText("Clientes");
        bClientes.setFocusable(false);
        bClientes.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        bClientes.setName("bClientes"); // NOI18N
        bClientes.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        bClientes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bClientesActionPerformed(evt);
            }
        });
        jToolBar1.add(bClientes);

        bPropietarios.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconos/user_business_32.png"))); // NOI18N
        bPropietarios.setText("Propietarios");
        bPropietarios.setFocusable(false);
        bPropietarios.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        bPropietarios.setName("bPropietarios"); // NOI18N
        bPropietarios.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        bPropietarios.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bPropietariosActionPerformed(evt);
            }
        });
        jToolBar1.add(bPropietarios);

        lpPrincipal.setLayout(new javax.swing.OverlayLayout(lpPrincipal));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lpPrincipal)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lpPrincipal)
                .addContainerGap())
        );

        setSize(new java.awt.Dimension(582, 442));
        setLocationRelativeTo(null);
    }// </editor-fold>//GEN-END:initComponents

    private void bInmueblesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bInmueblesActionPerformed
        // Marco como selected el boton Inmueble
        this.bClientes.setSelected(false);
        this.bInmuebles.setSelected(true);
        this.bPropietarios.setSelected(false);
        
        this.lpPrincipal.removeAll();
        this.lpPrincipal.add(new PListadoInmuebles());
        this.getContentPane().revalidate();
    }//GEN-LAST:event_bInmueblesActionPerformed

    private void bClientesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bClientesActionPerformed
        this.bClientes.setSelected(true);
        this.bInmuebles.setSelected(false);
        this.bPropietarios.setSelected(false);
        
        this.lpPrincipal.removeAll();
        this.lpPrincipal.add(new PListadoClientes());
        this.getContentPane().revalidate();
    }//GEN-LAST:event_bClientesActionPerformed

    private void bPropietariosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bPropietariosActionPerformed
        this.bClientes.setSelected(false);
        this.bInmuebles.setSelected(false);
        this.bPropietarios.setSelected(true);

        this.lpPrincipal.removeAll();
        this.lpPrincipal.add(new PListadoPropietarios());
        this.getContentPane().revalidate();
    }//GEN-LAST:event_bPropietariosActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(VPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(VPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(VPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(VPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new VPrincipal(null).setVisible(true);
            }
        });
    }
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton bClientes;
    private javax.swing.JButton bInmuebles;
    private javax.swing.JButton bPropietarios;
    private javax.swing.JToolBar jToolBar1;
    private javax.swing.JLayeredPane lpPrincipal;
    // End of variables declaration//GEN-END:variables
}
